package ru.tpu.osu.faces.dao;

import java.io.Serializable;

import javax.persistence.*;

@Entity
public class Student implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8190388682596399689L;
	@Id
	private String login;
	
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	
	@OneToOne(cascade = CascadeType.ALL)
    @PrimaryKeyJoinColumn
	private User user;
	
	@ManyToOne
	@JoinColumn(name="group_fk", nullable=false)
	private Group group;
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Group getGroup() {
		return group;
	}
	public void setGroup(Group group) {
		this.group = group;
	}
	public String getShortName() {
		if (getUser() != null)
			return getUser().getShortName();
		return "";
	}
	public String toString() {
		return getShortName();
	}
}
